<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>MVVM的概念</title>
    <script>
        var msg="数据变量";
        window.onload=function(){
            // let p1=document.getElementById("pDom");
            // let p2=document.querySelector("pDom");
            // p1.innerHTML=msg;
            initDom();
            let i1=document.getElementById("inputDom");
            i1.value=msg;
            // i1.addEventListener("input",function(){});
            i1.addEventListener("input",inputDom);
        };
        function inputDom(){
            // console.log(this);
            msg=this.value;
            initDom();
        };
        // function inputDom(a,b,c){
        //     console.log(a);//this指代触发元素本身Dom元素
        //     console.log(b);//当前输入框的value值
        //     msg=b;
        //     initDom();
        // };
        function initDom(){
            let p1=document.getElementById("pDom");
            // let p2=document.querySelector("pDom");
            p1.innerHTML=msg;
        }
    </script>
</head>
<body>
    <p id="pDom"></p>
    <!-- <input type="text" id="inputDom" oninput="inputDom(this,this.value)"> -->
    <input type="text" id="inputDom">
</body>
</html>